#include "VoETelephoneEventObserverImpl.h"


VoETelephoneEventObserverImpl::VoETelephoneEventObserverImpl(void)
{
	m_mid_OnReceivedTelephoneEventInband = 0;
	m_mid_OnReceivedTelephoneEventOutOfBand = 0;
}


VoETelephoneEventObserverImpl::~VoETelephoneEventObserverImpl(void)
{
}

bool VoETelephoneEventObserverImpl::init_jni(JNIEnv* env)
{
	bool result = false;

	do 
	{
		m_mid_OnReceivedTelephoneEventInband = (env)->GetMethodID(m_cls, "onReceivedTelephoneEventInband", "(IIZ)V");
		if(!m_mid_OnReceivedTelephoneEventInband)
			break;

		m_mid_OnReceivedTelephoneEventOutOfBand = (env)->GetMethodID(m_cls, "onReceivedTelephoneEventOutOfBand", "(IIZ)V");
		if(!m_mid_OnReceivedTelephoneEventOutOfBand)
			break;

		result = true;

	} while (false);

	return result;
}

void VoETelephoneEventObserverImpl::OnReceivedTelephoneEventInband(
	int channel,
	int eventCode,
	bool endOfEvent)
{
	JNIEnv* env = 0;

	if(before(&env))
	{
		(env)->CallVoidMethod(m_obj, m_mid_OnReceivedTelephoneEventInband, channel, eventCode, endOfEvent);

		after(env);
	}
}

void VoETelephoneEventObserverImpl::OnReceivedTelephoneEventOutOfBand(
	int channel,
	int eventCode,
	bool endOfEvent)
{
	JNIEnv* env = 0;

	if(before(&env))
	{
		(env)->CallVoidMethod(m_obj, m_mid_OnReceivedTelephoneEventOutOfBand, channel, eventCode, endOfEvent);

		after(env);
	}
}